//
//  BaseTableViewController.m
//  coca
//
//  Created by 张帅 on 15/9/27.
//  Copyright © 2015年 ZhangShuai. All rights reserved.
//

#import "BaseTableViewController.h"
#import "VisitorLoginView.h"
#import "OAuthViewController.h"

#import "UserAccountViewModel.h"
@interface BaseTableViewController ()

@end

@implementation BaseTableViewController



- (BOOL)userLogon{
    
    return [[UserAccountViewModel sharedUserAccount] userLogon];
    
//    return  NO;
}

-(void)loadView{
    
    self.userLogon ? [super loadView]:[self setupVistorView];
    
}

//

-(void)viewDidAppear:(BOOL)animated {

    [super viewDidAppear:animated];
    
    NSLog(@"%@",_visitorView);
}


-(void) setupVistorView{
    // 替换根视图
    
    VisitorLoginView *visitorView =[[VisitorLoginView alloc] init];
    
    self.visitorView  = visitorView;
    
   
    self.view =  self.visitorView;
    
    // 设置导航按钮
    //
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(visitorLoginViewWillRegister)];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"登录" style:UIBarButtonItemStylePlain target:self action:@selector(visitorLoginViewWillLogin)];
    
    [self.visitorView.loginButton addTarget:self action:@selector(visitorLoginViewWillLogin) forControlEvents:(UIControlEventTouchUpInside)];
    [self.visitorView.registerButton addTarget:self action:@selector(visitorLoginViewWillRegister) forControlEvents:(UIControlEventTouchUpInside)];
}


- (void)visitorLoginViewWillLogin{

    OAuthViewController *oauth =[[ OAuthViewController alloc] init];
    
    UINavigationController *navVc =[[UINavigationController alloc]initWithRootViewController:oauth];
    
    [self.navigationController presentViewController:navVc animated:true completion:nil];
    
    

    
    NSLog(@"登录1");

}
-(void)visitorLoginViewWillRegister{
    
  NSLog(@"注册1");
    
}

@end
